import { createBrowserRouter } from "react-router-dom";

class BrowserRouter {
  routes = [];
  browserRouter = null;

  constructor({ routes }) {
    this.routes = routes || [];
    this.create();
    this.beforeEach = function () {};
    this.afterEach = function () {};
  }
  create() {
    if (!this.routes.length) return;
    this.browserRouter = createBrowserRouter(this.routes);
  }
  setRoutes(values) {
    this.routes = values;
    this.create();
  }
  addRoutes(values) {
    this.routes = this.routes.concat(values);
    this.create();
  }
}

export default BrowserRouter;
